
Type NewProjectWindow Extends ToolWindow

	Method New()
	
		ToolType = 2
	
	End Method


	Method Update(EID:Int,Obj:Object,EEX : Object = Null)
	
	
		Select EID
		
			Case EVENT_GADGETACTION
				Select Obj
				
					Case Gadgets[2]
						If FileType("Projects/"+TextFieldText(Gadgets[1])) = 0 Then
							Local filedir : String = TextFieldText(Gadgets[1])
							CreateDir("Projects/"+filedir)
							CreateDir("Projects/"+filedir+"/Images")
							CreateDir("Projects/"+filedir+"/Tilesets")
							CreateDir("Projects/"+filedir+"/Maps")
							CreateDir("Projects/"+filedir+"/Objects")
							CreateDir("Projects/"+filedir+"/Music")
							CreateDir("Projects/"+filedir+"/Sounds")
							CreateDir("Projects/"+filedir+"/Scripts")
							CreateDir("Projects/"+filedir+"/Sprites")

							Notify "Project Created"
							FreeGadget Window
							ListRemove(ParentList,Self)		
													
							If MainEd <> Null Then
								If MainEd.MainWindow <> Null Then
									FreeGadget MainEd.MainWindow	
								EndIf
							EndIf
							If Proj <> Null Then
							
								FreeGadget Proj.Window
								Proj = Null
							
							EndIf							
							CurrentProject = filedir
							Config.SaveConfig()
							AppTitle = "Spaget - "+filedir
							MainEd = New Editor_Main
							MainEd.Init()
							
						Else
							Notify "Project Already Exists"
						EndIf
					
					Case Gadgets[3]
						FreeGadget Window
						ListRemove(ParentList,Self)
				
				End Select
	
	
		End Select
	End Method



	Method Set()
		Local Gads : TGadget[4]
		
		Window = CreateWindow( Title,Pos.x,Pos.y,Pos.w,Pos.h,Null,WINDOW_TITLEBAR|WINDOW_TOOL|WINDOW_CENTER )	
		
		Gads[0] = CreateLabel("Project Name:",10,10,100,20,Window)
		Gads[1] = CreateTextField(10,30,ClientWidth(Window)-20,20,Window)
		Gads[2] = CreateButton("Create Project",10,60,150,20,Window)
		Gads[3] = CreateButton("Cancel",170,60,150,20,Window)
		
		Gadgets = Gads
	
	
	End Method


End Type